package com.petRescueCenter.demo.user.dao;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import com.petRescueCenter.demo.user.entity.User;

@Repository
public interface UserDao extends PagingAndSortingRepository<User, Long>, JpaSpecificationExecutor<User> {

	@Query("select count(*) from Pet p left join p.owner o where o.id=?1 ")
	public int getAdoptTimes(Long id);

	@Query("select count(*) from Posting p left join p.fans a where a.id = ?1 ")
	public int getAttentionTimes(Long id);

	@Query("select count(*) from Posting p left join p.author a where a.id = ?1 ")
	public int getPostTimes(Long id);

	/*
	 * @Query("select count(*) from Voluntary v left join v.volunteers a where a.id = ?1 "
	 * ) public int getVoluntaryTimes(Long id);
	 */

	public User findByName(String name);

}
